<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增banner配置')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tBanner-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">图片地址：</label>
                <div class="col-sm-8">
                    <input name="img" id="img" class="form-control" type="hidden" required>
                    <div class="file-loading">
                        <input id="singleFile" name="file" type="file" multiple data-min-file-count="1" data-theme="fas">
                    </div>


                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">跳转地址：</label>
                <div class="col-sm-8">
                    <input name="act" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">顺序：</label>
                <div class="col-sm-8">
                    <input name="sort" class="form-control" type="text">
                </div>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label class="col-sm-3 control-label">状态：</label>
                    <div class="col-sm-9">
                        <select class="form-control" name="status">
                            <option value="2">正常</option>
                            <option value="1">待发布</option>
                            <option value="3">删除</option>
                        </select>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
        var prefix = ctx + "bajiaostar/tBanner"
        $("#form-tBanner-add").validate({
            focusCleanup: true
        });
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-tBanner-add').serialize());
            }
        }
        $(document).ready(function() {
            $('#singleFile').fileinput({
                language: 'zh', // 设置语言
                uploadUrl: '/common/upload', // 上传的地址
                //allowedFileExtensions: ['jpg', 'png', 'gif'], // 允许的文件格式
                showUpload: true, // 是否显示上传按钮
                showRemove: false, // 是否显示移除按钮
                showPreview: true, // 是否显示预览
                showCaption: true, // 是否显示标题
                browseClass: "btn btn-primary", // 按钮样式
                dropZoneEnabled: false, // 是否显示拖拽区域
                maxFileSize: 1024, // 最大文件大小
            }).on('fileuploaded', function(event, data, previewId, index) {
                // 文件上传成功后的处理逻辑
                var response = data.response;
                if (response.code !=0){
                    $.modal.alertWarning("文件上传失败");
                }
                $('#img').val(response.url);
                console.log(response);
            });
        });

    </script>
</body>
</html>